
mod result_test;
mod trait_test;

use trait_test::Area; //NOTE: 要使用trait的接口，必须引用.

fn main() {
    println!("Hello, panic!");

    // panic!("crash and burn.");

    // let v = vec![1, 2, 3];
    // v[99]; // panic

    result_test::test();

    match result_test::read_username() {
        Ok(s) => println!("name is {}", s),
        Err(e) => println!("读取文件错误：{:?}", e),
    };

    match result_test::read_username2() {
        Ok(name) => println!("名称是：{}", name),
        Err(e) => println!("错误：{:?}", e),
    }

    match result_test::read_username3() {
        Ok(name) => println!("name3: {}", name),
        Err(e) => println!("error: {:?}", e),
    }


    let c = trait_test::Circle{r: 0.5};
    println!("面积：{}", c.area());
}
